<?php

   class query
   {
      private static function conexion()
      {         
         $mysqli = new mysqli("mysql.hostinger.co","u217270572_ptp","pidetuplato","u217270572_ptp"); 
         return $mysqli;      
      }

      public static function consultar($campos,$tabla,$condiciones)
      {
         $conexion=query::conexion();
         $consulta="select ".$campos." from ".$tabla." ".$condiciones.";";
         $query_consulta=$conexion->query($consulta);
         $query_campos=$query_consulta->fetch_fields();
         echo "<table border='1'>";
         echo "<tr>";
         foreach ($query_campos as $valor) {
               echo "<th>";
               echo $valor->name;
               echo "</th>";
            }
            echo "</tr>";
         while($registro = $query_consulta->fetch_assoc())
         {
            echo "<tr>";
            foreach ($query_campos as $valor) {
               echo "<td>";
               echo $registro[$valor->name];
               echo "</td>";
            }
            echo "</tr>";
         }
         echo "</table>";
         $conexion=null;
      }
      public static function insertar($tabla,$campos,$valores)
      {

         $conexion=query::conexion();
         $consulta="insert into ".$tabla."(".$campos.") values(".$valores."); ";
         $query_consulta=$conexion->query($consulta);
         $conexion=null;

      }

   }

?>